import pandas as pd

df = pd.read_csv("D:\py\pythonProject\population-data\data\originalData\家庭结构年度数据 .csv", skiprows=2,encoding="gbk")
df=df.iloc[:-2]
df['指标'] = df['指标'].str.replace('户数(人口抽样调查)(户)', '', regex=False)

first_row = df.iloc[0]
df_normalized = df.copy()
df_normalized.iloc[1:, 1:] = df.iloc[1:, 1:].div(first_row[1:], axis=1)
df_normalized=df_normalized.drop(df_normalized.index[0])

df_normalized.iloc[:, 1:] = df_normalized.iloc[:, 1:].applymap(lambda x: round(x * 100, 2))
df_normalized.to_csv(r"D:\py\pythonProject\population-data\data\temp\家庭结构_2.csv",encoding="gbk")